﻿using Coolzon.UI.Core.XProperty;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace Coolzon.UI.Core
{
    public partial class Area
    {
        public static XPropertyDescription XBackground = new XPropertyDescription(typeof(Area), "Background", "other", "背景颜色", null);
        public static XPropertyDescription XForeground = new XPropertyDescription(typeof(Area), "Foreground", "other", "前景色", null);

        public static XPropertyDescription XWidth = new XPropertyDescription(typeof(Area), "Width", "other", "宽度", null);
        public static XPropertyDescription XHeight = new XPropertyDescription(typeof(Area), "Height", "other", "高度", null);

        [Category("Layout")]
        [DisplayName("左部距离")]
        [Description("Left")]
        //[Editor(typeof(XProperty.Editors.XDoubleEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Layout, "Left", "左部距离")]
        public double Left
        {
            get
            {
                return (double)GetValue(XLeftProperty);
            }
            set
            {
                SetValue(XLeftProperty, value);
            }
        }

        [Category("Layout")]
        [DisplayName("上部距离")]
        [Description("Top")]
        //[Editor(typeof(XProperty.Editors.XDoubleEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Layout, "Top", "上部距离")]
        public double Top
        {
            get
            {
                return (double)GetValue(XTopProperty);
            }
            set
            {
                SetValue(XTopProperty, value);
            }
        }

        public static DependencyProperty XLeftProperty = DependencyProperty.Register("Left",
            typeof(double),
            typeof(Area),
            new PropertyMetadata(default(double), XLeftPropertyChangedCallback));

        public static DependencyProperty XTopProperty = DependencyProperty.Register("Top",
            typeof(double),
            typeof(Area),
            new PropertyMetadata(default(double), XTopPropertyChangedCallback));


        private static void XLeftPropertyChangedCallback(DependencyObject @object, DependencyPropertyChangedEventArgs e)
        {
            Area instance = @object as Area;
            System.Windows.Controls.Canvas.SetLeft(instance, (double)e.NewValue);
        }

        private static void XTopPropertyChangedCallback(DependencyObject @object, DependencyPropertyChangedEventArgs e)
        {
            Area instance = @object as Area;
            System.Windows.Controls.Canvas.SetTop(instance, (double)e.NewValue);
        }

        /// <summary>
        /// 标题描述属性
        /// </summary>
        [Category("Appearance")]
        [DisplayName("标题")]
        [Description("Header")]
        //[Editor(typeof(XProperty.Editors.XStringEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "Header", "标题")]
        public string XHeader
        {
            get
            {
                return (string)GetValue(XHeaderProperty);
            }
            set
            {
                SetValue(XHeaderProperty, value);
            }
        }

        /// <summary>
        /// 是否显示查询面板
        /// </summary>
        public bool IsShowQueryPanel
        {
            get
            {
                return (bool)GetValue(IsShowQueryPanelProperty);
            }
            set
            {
                SetValue(IsShowQueryPanelProperty, value);
            }
        }

        #region dependency property
        private static void propertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //Area Area = d as Area;
            //Area.RaisePropertyChanged(e.Property.Name);
            //Area.Refresh();
        }

        public static DependencyProperty XHeaderProperty = DependencyProperty.Register("XHeader",
            typeof(string),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));

        public static DependencyProperty XIsShowHeaderProperty = DependencyProperty.Register("XIsShowHeader",
            typeof(bool),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));

        public static DependencyProperty IsShowQueryPanelProperty = DependencyProperty.Register("IsShowQueryPanel",
            typeof(bool),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));

        public static DependencyProperty XHeaderBackgroundImageProperty = DependencyProperty.Register("HeaderBackground",
            typeof(Brush),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderHeightProperty = DependencyProperty.Register("XHeaderHeight",
            typeof(double),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderWidthProperty = DependencyProperty.Register("XHeaderWidth",
            typeof(double),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderPaddingProperty = DependencyProperty.Register("XHeaderPadding",
            typeof(Thickness),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderForegroundProperty = DependencyProperty.Register("XHeaderForeground",
            typeof(Brush),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderFontSizeProperty = DependencyProperty.Register("XHeaderFontSize",
            typeof(double),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        public static DependencyProperty XHeaderFontProperty = DependencyProperty.Register("XHeaderFont",
            typeof(FontFamily),
            typeof(Area),
            new PropertyMetadata(propertyChangedCallback));
        #endregion

        #region XProperties

        [Category("Appearance")]
        [DisplayName("是否显示标题")]
        [Description("IsShowHeader")]
        //[Editor(typeof(XProperty.Editors.XBooleanEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "IsShowHeader", "是否显示标题")]
        public bool XIsShowHeader
        {
            get
            {
                return (bool)GetValue(XIsShowHeaderProperty);
            }
            set
            {
                SetValue(XIsShowHeaderProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题背景图片")]
        [Description("HeaderBackgroundImage")]
        //[Editor(typeof(XProperty.Editors.XImageSourceFileEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderBackground", "标题背景")]
        public Brush HeaderBackground
        {
            get
            {
                return (Brush)GetValue(XHeaderBackgroundImageProperty);
            }
            set
            {
                SetValue(XHeaderBackgroundImageProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题高度")]
        [Description("HeaderHeight")]
        //[Editor(typeof(XProperty.Editors.XDoubleEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderHeight", "标题高度")]
        public double XHeaderHeight
        {
            get
            {
                return (double)GetValue(XHeaderHeightProperty);
            }
            set
            {
                SetValue(XHeaderHeightProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题宽度")]
        [Description("HeaderWidth")]
        //[Editor(typeof(XProperty.Editors.XDoubleEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderWidth", "标题宽度")]
        public double XHeaderWidth
        {
            get
            {
                return (double)GetValue(XHeaderWidthProperty);
            }
            set
            {
                SetValue(XHeaderWidthProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题内边距")]
        [Description("HeaderPadding")]
        //[Editor(typeof(XProperty.Editors.XThicknessEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderPadding", "标题内边距")]
        public Thickness XHeaderPadding
        {
            get
            {
                return (Thickness)GetValue(XHeaderPaddingProperty);
            }
            set
            {
                SetValue(XHeaderPaddingProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题前景色")]
        [Description("HeaderForeground")]
        //[Editor(typeof(XProperty.Editors.XBrushEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderForeground", "标题前景色")]
        public Brush XHeaderForeground
        {
            get
            {
                return (Brush)GetValue(XHeaderForegroundProperty);
            }
            set
            {
                SetValue(XHeaderForegroundProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题字体大小")]
        [Description("HeaderFontSize")]
        //[Editor(typeof(XProperty.Editors.XDoubleEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderFontSize", "标题字体大小")]
        public double XHeaderFontSize
        {
            get
            {
                return (double)GetValue(XHeaderFontSizeProperty);
            }
            set
            {
                SetValue(XHeaderFontSizeProperty, value);
            }
        }

        [Category("Appearance")]
        [DisplayName("标题字体")]
        [Description("HeaderFont")]
        //[Editor(typeof(XProperty.Editors.XFontFamilyEditor), typeof(XProperty.XPropertyValueEditor))]
        [XProperty(XPropertyCategory.Appearance, "HeaderFont", "标题字体")]
        public FontFamily XHeaderFont
        {
            get
            {
                return (FontFamily)GetValue(XHeaderFontProperty);
            }
            set
            {
                SetValue(XHeaderFontProperty, value);
            }
        }
        #endregion
    }
}
